package org.cary.lucene.query;

import org.apache.lucene.index.Term;
import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.PhraseQuery.Builder;
import org.cary.lucene.SearchBean;

public class QueryFactory {
	
	/**
	 * 生成对共享的查询
	 * @param bean
	 * @return
	 * @throws Exception
	 */
	public static Query buildShareQuery(SearchBean bean) throws Exception{
		String keyword = bean.getKeyword();
		Builder builder = new PhraseQuery.Builder();
		builder.setSlop(0);
		builder.add(new Term("content",keyword));
		return builder.build();
	}
}
